$(document).ready(function () {
$('.strt-name').live('click',function(){
           var code=$(this).attr('id');
           $('#'+code).removeClass('strt-name');
           jQuery.ajax({
           url:structure_url,
           data:{'code':code},
           type:'post',
           dataType:"json",
           success:function(result){
               var line_v='<div class="line-v"><span></span></div>';
               switch(result.size){
               case 0:
                   break;
               case 1:
                   var opid='#'+code;
                   var info=[];
                   $.each(result.data,function(i,item){
                    info.push(item);
                   })
                   var block='<div class="line-v"><span></span></div><div class="strt-part" style="position: relative;"><span class="strt-name"  id='+info[0]['code']+'>'+'<input type="checkbox" name="pick" id='+info[0]['code']+'>'+info[0]['name']+'-'+info[0]['code']+'</span></div>'
                   $(opid).append();
                    break;
               case 2:
                   var opid='#'+code;
                   $(opid).append(line_v);
                   var info=[];
                   $.each(result.data,function(i,item){
                    info.push(item);
                   })
                   var block_l='<div class="strt-part" style="position: relative;"><span class="line-h line-h-r"></span><div class="line-v"><span></span></div><span class="strt-name"  id='+info[0]['code']+'>'+'<input type="checkbox" name="pick" id='+info[0]['code']+'>'+info[0]['name']+'-'+info[0]['code']+'</span></div>'
                   var block_r='<div class="strt-part" style="position: relative;"><span class="line-h line-h-l"></span><div class="line-v"><span></span></div><span class="strt-name"  id='+info[1]['code']+'>'+'<input type="checkbox" name="pick" id='+info[1]['code']+'>'+info[1]['name']+'-'+info[1]['code']+'</span></div></div>'
                   $(opid).append(block_l);
                   $(opid).append(block_r);
                    break;
               default:
                   var block_c="";
                   var opid='#'+code;
                   $(opid).append(line_v);
                   var info=[];
                   $.each(result.data,function(i,item){
                     info.push(item);
                   })
                   $(opid).append('<div class="strt-block">');
                   var block_l='<div class="strt-part" style="position: relative;"><span class="line-h line-h-r"></span><div class="line-v"><span></span></div><span class="strt-name"  id='+info[0]['code']+'>'+'<input type="checkbox" name="pick" id='+info[0]['code']+'>'+info[0]['name']+'-'+info[0]['code']+'</span></div>';
                   $(opid).append(block_l);
                   for(var i=1;i<info.length-1;i++){
                       block_c+='<div class="strt-part" style="position: relative;"><span class="line-h line-h-c"></span><div class="line-v"><span></span></div><span class="strt-name" id='+info[i]['code']+'>'+'<input type="checkbox" name="pick" id='+info[i]['code']+'>'+info[i]['name']+'-'+info[i]['code']+'</span></div>'
                   }
                   $(opid).append(block_c);
                   var block_r='<div class="strt-part" style="position: relative;"><span class="line-h line-h-l"></span><div class="line-v"><span></span></div><span class="strt-name"  id='+info[info.length-1]['code']+'>'+'<input type="checkbox" name="pick" id='+info[info.length-1]['code']+'>'+info[info.length-1]['name']+'-'+info[info.length-1]['code']+'</span></div>';
                   $(opid).append(block_r);
                   $(opid).append('</div>');
                   break;
               }
           }
           });
});

});